home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
lang
/
fpcsrc.lha
/
fpc
/
compiler
/
options.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-09-24
|
35KB
|
1,183 lines
{
$Id: options.pas,v 1.3.2.2 1998/08/18 13:43:50 carl Exp $
Copyright (c) 1993-98 by the FPC development team
Reads command line options and config files
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit options;
interface
{$I optmsg.inc}
{$I optidx.inc}
type
POption=^TOption;
TOption=object
NoPressEnter,
Logowritten : boolean;
Constructor Init;
Destructor Done;
procedure Comment(l:longint;t:toptionconst);
procedure Comment1(l:longint;t:toptionconst;const s1:string);
procedure WriteLogo;
procedure WriteInfo;
procedure WriteHelpPages;
procedure IllegalPara(const opt:string);
procedure Setbool(const opts:string;var b:boolean);
procedure interpret_proc_specific_options(const opt:string);virtual;
procedure interpret_option(const opt :string);
procedure Interpret_file(const filename : string);
procedure Read_Parameters;
end;
procedure get_exepath;
procedure read_arguments;
implementation
uses
cobjects,globals,systems,
verbose,dos,scanner,link,verb_def,messages,os2_targ
{$ifdef i386}
,opts386
{$endif}
{$ifdef m68k}
,opts68k
{$endif}
;
const
page_size = 24;
{$ifdef i386}
ppccfg : string = 'pp68k.cfg';
{$else}
ppccfg : string = 'pp68k.cfg';
{$endif}
var
readfilename, { read filename from the commandline ? }
read_configfile, { read config file, set when a cfgfile is found }
target_is_set : boolean; { do not allow contradictory target settings }
msgfilename,
param_file : string; { file to compile specified on the commandline }
optionmsg : pmessage;
option : poption;
{****************************************************************************
Defines
****************************************************************************}
procedure def_symbol(const s : string);
begin
if s='' then
exit;
commandlinedefines.concat(new(pstring_item,init(upper(s))));
end;
procedure undef_symbol(const s : string);
var
item,next : pstring_item;
begin
if s='' then
exit;
item:=pstring_item(commandlinedefines.first);
while assigned(item) do
begin
if (item^.str^=s) then
begin
next:=pstring_item(item^.next);
commandlinedefines.remove(item);
item:=next;
end
else
if item<>pstring_item(item^.next) then
item:=pstring_item(item^.next)
else
break;
end;
end;
function check_symbol(const s:string):boolean;
var
hp : pstring_item;
begin
hp:=pstring_item(commandlinedefines.first);
while assigned(hp) do
begin
if (hp^.str^=s) then
begin
check_symbol:=true;
exit;
end;
hp:=pstring_item(hp^.next);
end;
check_symbol:=false;
end;
{****************************************************************************
Toption
****************************************************************************}
procedure Toption.Comment(l:longint;t:toptionconst);
begin
if (Verbosity and l)<>0 then
WriteLn(optionmsg^.Get(ord(t)));
end;
procedure Toption.Comment1(l:longint;t:toptionconst;const s1:string);
begin
if (Verbosity and l)<>0 then
WriteLn(optionmsg^.Get1(ord(t),s1));
end;
procedure Toption.WriteLogo;
var
i : toptionconst;
begin
if Logowritten then
exit;
for i:=logo_start to logo_end do
Comment1(V_Default,i,target);
Logowritten:=true;
end;
procedure Toption.WriteInfo;
var
i : toptionconst;
begin
for i:=info_start to info_end do
Comment(V_Default,i);
Stop;
end;
procedure Toption.WriteHelpPages;
function PadEnd(s:string;i:longint):string;
begin
while (length(s)<i) do
s:=s+' ';
PadEnd:=s;
end;
var
lastident,
i,j,
outline,
ident,
lines : longint;
show : boolean;
opt : string[32];
input,
s : string;
begin
Write(paramstr(0));
Comment(V_Default,usage);
lastident:=0;
if logowritten then
lines:=3
else
lines:=1;
for i:=1 to optionhelplines do
begin
{ get a line and reset }
s:=optionmsg^.Get(ord(endoptionconst)-1+i);
ident:=0;
show:=false;
{ parse options }
case s[1] of
{$ifdef i386}
'3',
{$endif}
{$ifdef m68k}
'6',
{$endif}
'*' : show:=true;
end;
if show then
begin
case s[2] of
{$ifdef linux}
'L',
{$endif}
{$ifdef os2}
'O',
{$endif}
'*' : show:=true;
else
show:=false;
end;
end;
{ now we may show the message or not }
if show then
begin
case s[3] of
'0' : begin
ident:=0;
outline:=0;
end;
'1' : begin
ident:=2;
outline:=7;
end;
'2' : begin
ident:=11;
outline:=9;
end;
'3' : begin
ident:=21;
outline:=6;
end;
end;
j:=pos('_',s);
opt:=Copy(s,4,j-4);
if opt='*' then
opt:=''
else
opt:=PadEnd('-'+opt,outline);
if (ident=0) and (lastident<>0) then
begin
Writeln;
inc(Lines);
end;
{ page full ? }
if (lines>=page_size) then
begin
if not NoPressEnter then
begin
write('*** press enter ***');
readln(input);
if upper(input)='Q' then
stop;
end;
lines:=0;
end;
WriteLn(PadEnd('',ident)+opt+Copy(s,j+1,255));
LastIdent:=Ident;
inc(Lines);
end;
end;
stop;
end;
procedure Toption.IllegalPara(const opt:string);
begin
Comment1(V_Default,illegal_para,opt);
Comment(V_Default,help_pages_para);
stop;
end;
procedure Toption.Setbool(const opts:string;var b:boolean);
var
i : longint;
begin
b:=true;
for i:=3 to length(opts) do
case opts[i] of
'-' : b:=false;
'+' : b:=true;
else
IllegalPara(opts);
end;
end;
procedure TOption.interpret_proc_specific_options(const opt:string);
begin
end;
procedure TOption.interpret_option(const opt:string);
var
code : word;
c : char;
more : string;
j : longint;
begin
if opt='' then
exit;
case opt[1] of
'-' : begin
more:=Copy(opt,3,255);
case opt[2] of
'?' : WriteHelpPages;
'h' : begin
NoPressEnter:=true;
WriteHelpPages;
end;
'a' : writeasmfile:=true;
{$ifdef tp}
'b' : setbool(opt,use_big);
{$endif}
'B' : if more='' then
do_build:=true
else
IllegalPara(opt);
'C' : begin
for j:=1 to length(more) do
case more[j] of
'a','e' : ;
'h' : begin
val(copy(more,j+1,length(more)-j),heapsize,code);
if (code<>0) or (heapsize>=67107840) or (heapsize<1024) then
IllegalPara(opt);
break;
end;
'i' : initswitches:=initswitches+[cs_iocheck];
'n' : initswitches:=initswitches+[cs_n